// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   responsiblePersonName_register_ok.java

package design.config.file;

import include.nseer_cookie.Divide1;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class responsiblePersonName_register_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public responsiblePersonName_register_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		nseer_db_backup1 design_db = new nseer_db_backup1(dbApplication);
		nseer_db_backup1 hr_db = new nseer_db_backup1(dbApplication);
		String fileKind_chain = request.getParameter("fileKind_chain");
		String chain_id = Divide1.getId(fileKind_chain);
		String chain_name = Divide1.getName(fileKind_chain);
		String responsible_person_ID = request.getParameter("responsible_person_ID");
		try
		{
			if (design_db.conn((String)dbSession.getAttribute("unit_db_name")) && hr_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String sqll = (new StringBuilder("select * from design_config_responsibleperson where chain_id='")).append(chain_id).append("' and chain_name='").append(chain_name).append("' and responsible_person_ID='").append(responsible_person_ID).append("'").toString();
				ResultSet rs = design_db.executeQuery(sqll);
				if (rs.next())
				{
					response.sendRedirect("design/config/file/responsiblePersonName_register_ok_a.jsp");
				} else
				{
					String sql2 = (new StringBuilder("select * from hr_file where human_ID='")).append(responsible_person_ID).append("'").toString();
					ResultSet rs2 = hr_db.executeQuery(sql2);
					if (rs2.next())
					{
						String sql = (new StringBuilder("insert into design_config_responsibleperson(chain_id,chain_name,responsible_person_ID,responsible_person_name) values('")).append(chain_id).append("','").append(chain_name).append("','").append(responsible_person_ID).append("','").append(rs2.getString("human_name")).append("')").toString();
						design_db.executeUpdate(sql);
						response.sendRedirect("design/config/file/responsiblePersonName_register_ok_b.jsp");
					} else
					{
						response.sendRedirect("design/config/file/responsiblePersonName_register_ok_c.jsp");
					}
				}
				design_db.commit();
				hr_db.commit();
				hr_db.close();
				design_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
